// 导入ComponentWithComputed
import { ComponentWithComputed } from "miniprogram-computed";
import { numStore } from "../../stores/numstore";
// 在使用了ComponentWithComputed构建的组件中绑定store
// 1.导入storeBindingsBehavior
import { storeBindingsBehavior } from "mobx-miniprogram-bindings";
// 使用ComponentWithComputed代替Component
ComponentWithComputed({
  // 2.注册使用storeBindingsBehavior
  behaviors: [storeBindingsBehavior],
  // 3.设置store配置项
  storeBindings: {
    store: numStore,
    fields: ["numA", "numB", "sum"],
    actions: ["update"],
  },
  data: {
    a: 10,
    b: 20,
  },
  // 使用计算属性
  computed: {
    total(data) {
      return data.a + data.b;
    },
  },
});
